<template>
    <el-dialog :title="$t('common.tips')" :visible.sync="showDialog" width="30%" >
        <div>
            <div>
                <span>{{ $t('common.name') }}:</span><span>{{data.userName}}</span>
            </div>
            <div>
                <span>{{ $t('common.phoneNum') }}:</span><span>{{data.userPhone}}</span>
            </div>
            <div>
                <span>{{ $t('system.appName') }}:</span><span>{{data.appName}}</span>
            </div>
        </div>
        <div>
            <div><span style="padding-right:20px">{{ $t('common.cancelBefore')}}:{{ $t('common.contactAmount')}}:{{formatCurrency(data.contractAmount)}}</span>  <span>{{$t('common.restRepay')}}:{{formatCurrency(latestRestRepay==''?0:latestRestRepay)}}</span></div>
            <div><span style="padding-right:20px">{{ $t('common.cancelAfter')}}:{{ $t('common.contactAmount')}}:{{formatCurrency(data.contractAmount)}}</span>  <span>{{$t('common.restRepay')}}:{{formatCurrency(latestRestRepay/1 + data.repayAmount/1)}}</span></div>
        </div>
        <div class="tips">
            {{$t('common.isSureCancelRepay')}}
        </div>
        <span slot="footer" class="dialog-footer">
            <el-button type="primary" @click="submint">确 定</el-button>
            <el-button @click="showDialog = false">取 消</el-button>
        </span>
    </el-dialog>
</template>

<script>
import filters from '@/libs/filters';

export default {
    props: {
       
    },
    data() {
        return {
            data:{},
            showDialog:false,
            latestRestRepay:0,
            formatCurrency:filters.formatCurrency
        };
    },
    methods: {
        submint(){
            console.warn()
            let params = {
                id:this.data.id,
                orderId:this.data.orderId,
                channelOrderId:this.data.repayOrderId,
                modifyRestRepayAmount:this.data.repayAmount,
                fee:this.data.repayFee?this.data.repayFee:0,
                tax:this.data.tax,
                receiptType:this.data.receiptType,
                domain:this.data.domain,
                appName:this.data.appName,
            }
            this.$api.finance.repay.cancelReceipt(params).then(res=>{
                const {status, data, error} = res;
                if ('1' === status && '00000000' === error) {
                    this.showDialog = false;
                    this.$message.success('Successfully cancelled repayment!');
                    this.$emit('submint')
                }
            })
        },
        getOrder() {
            let params = {
                orderId: this.data.orderId
            };
            this.$api.finance.repay.getRepayScheduleDtoByOrderId(params).then(res => {
                const { status, data, error } = res;
                if ('1' === status && '00000000' === error) {
                    this.showDialog = true;
                    this.latestRestRepay = data.restRepay;
                    // this.contractAmount=data.contractAmount;
                    // this.lateRepay=data.restRepay;
                }
            })
        },
        changeDialog(row){
            this.data=row;
            this.getOrder()
            console.warn('dasd')
        },
    }
}
</script>
<style lang="scss" scoped>
.tips{
    font-weight: bold;
    font-size: 23px;
    padding-top: 30px;
}

</style>